import Vue from 'vue'
import VueI18n from 'vue-i18n'
import elementEnLocale from 'element-ui/lib/locale/lang/en' // element-ui lang
import elementCnLocale from 'element-ui/lib/locale/lang/zh-CN'// element-ui lang
import elementTwLocale from 'element-ui/lib/locale/lang/zh-TW'// element-ui lang
import enLocale from './en'
import cnLocale from './cn'
import twLocale from './tw'
import store from '../store'

Vue.use(VueI18n)

const messages = {
  'en-us': {
    ...enLocale,
    ...elementEnLocale
  },
  'zh-cn': {
    ...cnLocale,
    ...elementCnLocale
  },
  'zh-tw': {
    ...twLocale,
    ...elementTwLocale
  }
}
const i18n = new VueI18n({
  // set locale
  // options: zh-cn | zh-tw | en-us
  locale: store.state.settings.language,
  // set locale messages
  messages
})

export default i18n
